package de.slothsoft.commons.swing.window.phase;

import java.awt.Container;

import javax.swing.JPanel;

public abstract class Phase<I> {

	private final I id;
	private final String title;
	private final Container baseComponent;
	private boolean initialized;
	private boolean showInNavigation = true;
	private final boolean hasNavigation = true;

	public Phase(I id, String title) {
		this.id = id;
		this.title = title;
		this.baseComponent = createBaseComponent();
	}

	public boolean isShowInNavigation() {
		return this.showInNavigation;
	}

	public void setShowInNavigation(boolean showInNavigation) {
		this.showInNavigation = showInNavigation;
	}

	protected Container createBaseComponent() {
		return new JPanel();
	}

	public final String getTitle() {
		return this.title;
	}

	public final Container getBaseComponent() {
		return this.baseComponent;
	}

	public final I getId() {
		return this.id;
	}

	public final boolean isInitialized() {
		return this.initialized;
	}

	public boolean hasNavigation() {
		return this.hasNavigation;
	}

	public final void createControls() {
		this.initialized = true;
		createControls(this.baseComponent);
	}

	protected abstract void createControls(Container parent);

	public void exitPhase() {
		// to be overriden
	}
}
